package com.letou.ls.ui;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.letou.ls.R;
import com.letou.ls.mode.AppConfigInfo;
import com.letou.ls.uitl.AppConfigManager;
import com.letou.ls.uitl.CorlorSettingPreferencesUtils;
import com.letou.ls.view.ColorButton;
import com.letou.ls.view.PriorityDlg;
import com.letou.ls.view.PriorityDlg.SelectItemListener;
import com.letou.ls.view.SelectButton;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

/**
 * 颜色设置
 *
 * @author libin
 *
 *         2016年6月23日
 */
public class CorlorSettingActivity extends Activity implements OnClickListener {
    
    private int currentOrientation;
    
    private ColorButton bg_color_danshu; // 单数背景颜色
    private ColorButton bg_color_shuangshu;// 双数背景颜色


    // 期号
    private ColorButton title_color_qihao;// 标题字体颜色
    private ColorButton title_bg_color_qihao;// 标题背景颜色
    private ColorButton color_qihao;// 字体颜色
    private ColorButton bg_color_qihao;// 背景颜色

    // 前三直期号
    private ColorButton title_color_qiansanzhi;// 标题字体颜色
    private ColorButton title_bg_color_qiansanzhi;// 标题背景颜色
    private ColorButton color_qiansanzhi;// 字体颜色
    private ColorButton bg_color_qiansanzhi;// 背景颜色
    
    // 开奖号码分布
    private ColorButton title_color_kaijiang;// 标题字体颜色
    private ColorButton title_bg_color_kaijiang;// 标题背景颜色
    private ColorButton color_kaijiang;// 字体颜色
    private ColorButton bg_color_kaijiang;// 背景颜色
    private ColorButton double_bg_color_kaijiang;// 连号背景颜色
    
    // 前三分布
    private ColorButton title_color_qiansanfenbu;// 标题字体颜色
    private ColorButton title_bg_color_qiansanfenbu;// 标题背景颜色
    private ColorButton color_qiansanfenbu;// 字体颜色
    private ColorButton bg_color_qiansanfenbu;// 背景颜色
    private ColorButton double_bg_color_qiansanfenbu;// 连号背景颜色
    private ColorButton line_color_qiansanfenbu;// 折线颜色
    
    // 统计值
    private ColorButton title_color_tongjizhi;// 标题字体颜色
    private ColorButton title_bg_color_tongjizhi;// 标题背景颜色
    private ColorButton color_tongjizhi;// 字体颜色
    private ColorButton bg_color_tongjizhi;// 背景颜色
    
    
    // 推荐号码
    private ColorButton title_color_tuijian;// 标题字体颜色
    private ColorButton title_bg_color_tuijian;// 标题背景颜色
    private ColorButton color_tuijian;// 字体颜色
    private ColorButton bg_color_tuijian;// 背景颜色

    // 普通分割线
    private SelectButton line_common_small;// 细
    private SelectButton line_common_big;// 粗
    private ColorButton line_common_h;// 横线颜色
    private ColorButton line_common_v;// 竖线颜色

    // 区域分割线
    private SelectButton line_rect_small;// 细
    private SelectButton line_rect_big;// 粗
    private ColorButton line_rect_h;// 横线颜色
    private ColorButton line_rect_v;// 竖线颜色
    
    
    private PriorityDlg mPriorityDlg;
    private Button bt_commit;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        mPriorityDlg = new PriorityDlg(this);
        currentOrientation =
                getIntent().getIntExtra("orientation", Configuration.ORIENTATION_LANDSCAPE);
        if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            setContentView(R.layout.activity_color_setting_landscape);
        } else {
            setContentView(R.layout.activity_color_setting_portrait);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        bt_commit = (Button) findViewById(R.id.bt_commit);
        bt_commit.setOnClickListener(this);
        
        bg_color_danshu = (ColorButton) findViewById(R.id.bg_color_danshu);
        bg_color_danshu.setText("单数背景");
        bg_color_danshu.setOnClickListener(this);

        bg_color_shuangshu = (ColorButton) findViewById(R.id.bg_color_shuangshu);
        bg_color_shuangshu.setText("双数背景");
        bg_color_shuangshu.setOnClickListener(this);

        // 期号
        initQiHaoSettings();
        // 前三直
        initQianSanZhiSettings();
        // 开奖号码分布
        initKaiJIiangSettings();
        // 前三分布
        initQianSanFenBuSettings();
        // 统计值
        initTongJiZhiSettings();
        // 推荐号码
        initTuiJiangSettings();
        // 分割线
        initLineSettings();
        // String[] add_list = getResources().getStringArray(R.array.corlors);
        //
        // mPriorityDlg.setList(Arrays.asList(add_list));
        mPriorityDlg.setList(getColorList());
        
        
        updateColorConfigs();
    }



    private void initLineSettings() {
        // 普通分割线
        line_common_small = (SelectButton) findViewById(R.id.line_common_small);
        line_common_small.setText("细");
        line_common_small.setOnClickListener(this);
        
        line_common_big = (SelectButton) findViewById(R.id.line_common_big);
        line_common_big.setText("粗");
        line_common_big.setOnClickListener(this);
        
        line_common_h = (ColorButton) findViewById(R.id.line_common_h);
        line_common_h.setText("横线颜色");
        line_common_h.setOnClickListener(this);
        
        line_common_v = (ColorButton) findViewById(R.id.line_common_v);
        line_common_v.setText("竖线颜色");
        line_common_v.setOnClickListener(this);
        
        
        // 区域分割线
        line_rect_small = (SelectButton) findViewById(R.id.line_rect_small);
        line_rect_small.setText("细");
        line_rect_small.setSelectButton(true);
        line_rect_small.setOnClickListener(this);
        
        line_rect_big = (SelectButton) findViewById(R.id.line_rect_big);
        line_rect_big.setText("粗");
        line_rect_big.setSelectButton(true);
        line_rect_big.setOnClickListener(this);
        
        line_rect_h = (ColorButton) findViewById(R.id.line_rect_h);
        line_rect_h.setText("横线颜色");
        line_rect_h.setOnClickListener(this);
        
        line_rect_v = (ColorButton) findViewById(R.id.line_rect_v);
        line_rect_v.setText("竖线颜色");
        line_rect_v.setOnClickListener(this);
        
        
    }


    private void initTuiJiangSettings() {
        
        title_color_tuijian = (ColorButton) findViewById(R.id.title_color_tuijian);
        title_color_tuijian.setText("标题字体");
        title_color_tuijian.setOnClickListener(this);

        title_bg_color_tuijian = (ColorButton) findViewById(R.id.title_bg_color_tuijian);
        title_bg_color_tuijian.setText("标题背景");
        title_bg_color_tuijian.setOnClickListener(this);

        color_tuijian = (ColorButton) findViewById(R.id.color_tuijian);
        color_tuijian.setText("字体");
        color_tuijian.setOnClickListener(this);

        bg_color_tuijian = (ColorButton) findViewById(R.id.bg_color_tuijian);
        bg_color_tuijian.setText("背景");
        bg_color_tuijian.setOnClickListener(this);
        
        
    }
    
    
    
    private void initTongJiZhiSettings() {
        
        title_color_tongjizhi = (ColorButton) findViewById(R.id.title_color_tongjizhi);
        title_color_tongjizhi.setText("标题字体");
        title_color_tongjizhi.setOnClickListener(this);

        title_bg_color_tongjizhi = (ColorButton) findViewById(R.id.title_bg_color_tongjizhi);
        title_bg_color_tongjizhi.setText("标题背景");
        title_bg_color_tongjizhi.setOnClickListener(this);

        color_tongjizhi = (ColorButton) findViewById(R.id.color_tongjizhi);
        color_tongjizhi.setText("字体");
        color_tongjizhi.setOnClickListener(this);

        bg_color_tongjizhi = (ColorButton) findViewById(R.id.bg_color_tongjizhi);
        bg_color_tongjizhi.setText("背景");
        bg_color_tongjizhi.setOnClickListener(this);
        
        
    }



    private void initQianSanFenBuSettings() {
        
        title_color_qiansanfenbu = (ColorButton) findViewById(R.id.title_color_qiansanfenbu);
        title_color_qiansanfenbu.setText("标题字体");
        title_color_qiansanfenbu.setOnClickListener(this);

        title_bg_color_qiansanfenbu = (ColorButton) findViewById(R.id.title_bg_color_qiansanfenbu);
        title_bg_color_qiansanfenbu.setText("标题背景");
        title_bg_color_qiansanfenbu.setOnClickListener(this);

        color_qiansanfenbu = (ColorButton) findViewById(R.id.color_qiansanfenbu);
        color_qiansanfenbu.setText("字体");
        color_qiansanfenbu.setOnClickListener(this);

        bg_color_qiansanfenbu = (ColorButton) findViewById(R.id.bg_color_qiansanfenbu);
        bg_color_qiansanfenbu.setText("背景");
        bg_color_qiansanfenbu.setOnClickListener(this);
        
        double_bg_color_qiansanfenbu =
                (ColorButton) findViewById(R.id.double_bg_color_qiansanfenbu);
        double_bg_color_qiansanfenbu.setText("连号背景");
        double_bg_color_qiansanfenbu.setOnClickListener(this);

        line_color_qiansanfenbu = (ColorButton) findViewById(R.id.line_color_qiansanfenbu);
        line_color_qiansanfenbu.setText("折线");
        line_color_qiansanfenbu.setOnClickListener(this);
    }
    
    
    private void initKaiJIiangSettings() {
        
        title_color_kaijiang = (ColorButton) findViewById(R.id.title_color_kaijiang);
        title_color_kaijiang.setText("标题字体");
        title_color_kaijiang.setOnClickListener(this);

        title_bg_color_kaijiang = (ColorButton) findViewById(R.id.title_bg_color_kaijiang);
        title_bg_color_kaijiang.setText("标题背景");
        title_bg_color_kaijiang.setOnClickListener(this);

        color_kaijiang = (ColorButton) findViewById(R.id.color_kaijiang);
        color_kaijiang.setText("字体");
        color_kaijiang.setOnClickListener(this);

        bg_color_kaijiang = (ColorButton) findViewById(R.id.bg_color_kaijiang);
        bg_color_kaijiang.setText("背景");
        bg_color_kaijiang.setOnClickListener(this);
        
        double_bg_color_kaijiang = (ColorButton) findViewById(R.id.double_bg_color_kaijiang);
        double_bg_color_kaijiang.setText("连号背景");
        double_bg_color_kaijiang.setOnClickListener(this);
    }



    private void initQianSanZhiSettings() {
        
        title_color_qiansanzhi = (ColorButton) findViewById(R.id.title_color_qiansanzhi);
        title_color_qiansanzhi.setText("标题字体");
        title_color_qiansanzhi.setOnClickListener(this);

        title_bg_color_qiansanzhi = (ColorButton) findViewById(R.id.title_bg_color_qiansanzhi);
        title_bg_color_qiansanzhi.setText("标题背景");
        title_bg_color_qiansanzhi.setOnClickListener(this);

        color_qiansanzhi = (ColorButton) findViewById(R.id.color_qiansanzhi);
        color_qiansanzhi.setText("字体");
        color_qiansanzhi.setOnClickListener(this);

        bg_color_qiansanzhi = (ColorButton) findViewById(R.id.bg_color_qiansanzhi);
        bg_color_qiansanzhi.setText("背景");
        bg_color_qiansanzhi.setOnClickListener(this);
    }
    
    
    
    private void initQiHaoSettings() {
        
        title_color_qihao = (ColorButton) findViewById(R.id.title_color_qihao);
        title_color_qihao.setText("标题字体");
        title_color_qihao.setOnClickListener(this);

        title_bg_color_qihao = (ColorButton) findViewById(R.id.title_bg_color_qihao);
        title_bg_color_qihao.setText("标题背景");
        title_bg_color_qihao.setOnClickListener(this);

        color_qihao = (ColorButton) findViewById(R.id.color_qihao);
        color_qihao.setText("字体");
        color_qihao.setOnClickListener(this);

        bg_color_qihao = (ColorButton) findViewById(R.id.bg_color_qihao);
        bg_color_qihao.setText("背景");
        bg_color_qihao.setOnClickListener(this);
    }



    private void updateColorConfigs() {
        AppConfigInfo info =
                AppConfigManager.getInstance(getApplicationContext()).initColorsettingConfigs();
        bg_color_danshu.setItemCorlor(info.getBg_color_danshu());
        bg_color_shuangshu.setItemCorlor(info.getBg_color_shuangshu());

        title_color_qihao.setItemCorlor(info.getTitle_color_qihao());
        title_bg_color_qihao.setItemCorlor(info.getTitle_bg_color_qihao());
        color_qihao.setItemCorlor(info.getColor_qihao());
        bg_color_qihao.setItemCorlor(info.getBg_color_qihao());

        title_color_qiansanzhi.setItemCorlor(info.getTitle_color_qiansanzhi());
        title_bg_color_qiansanzhi.setItemCorlor(info.getTitle_bg_color_qiansanzhi());
        color_qiansanzhi.setItemCorlor(info.getColor_qiansanzhi());
        bg_color_qiansanzhi.setItemCorlor(info.getBg_color_qiansanzhi());

        title_color_kaijiang.setItemCorlor(info.getTitle_color_kaijiang());
        title_bg_color_kaijiang.setItemCorlor(info.getTitle_bg_color_kaijiang());
        color_kaijiang.setItemCorlor(info.getColor_kaijiang());
        bg_color_kaijiang.setItemCorlor(info.getBg_color_kaijiang());
        double_bg_color_kaijiang.setItemCorlor(info.getDouble_bg_color_kaijiang());

        title_color_qiansanfenbu.setItemCorlor(info.getTitle_color_qiansanfenbu());
        title_bg_color_qiansanfenbu.setItemCorlor(info.getTitle_bg_color_qiansanfenbu());
        color_qiansanfenbu.setItemCorlor(info.getColor_qiansanfenbu());
        bg_color_qiansanfenbu.setItemCorlor(info.getBg_color_qiansanfenbu());
        double_bg_color_qiansanfenbu.setItemCorlor(info.getDouble_bg_color_qiansanfenbu());
        line_color_qiansanfenbu.setItemCorlor(info.getLine_color_qiansanfenbu());

        title_color_tongjizhi.setItemCorlor(info.getTitle_color_tongjizhi());
        title_bg_color_tongjizhi.setItemCorlor(info.getTitle_bg_color_tongjizhi());
        color_tongjizhi.setItemCorlor(info.getColor_tongjizhi());
        bg_color_tongjizhi.setItemCorlor(info.getBg_color_tongjizhi());

        title_color_tuijian.setItemCorlor(info.getTitle_color_tuijian());
        title_bg_color_tuijian.setItemCorlor(info.getTitle_bg_color_tuijian());
        color_tuijian.setItemCorlor(info.getColor_tuijian());
        bg_color_tuijian.setItemCorlor(info.getBg_color_tuijian());

        line_common_small.setSelectButton(info.getLine_common_small());
        line_common_big.setSelectButton(info.getLine_common_big());
        line_common_h.setItemCorlor(info.getLine_common_h());
        line_common_v.setItemCorlor(info.getLine_common_v());

        line_rect_small.setSelectButton(info.getLine_rect_small());
        line_rect_big.setSelectButton(info.getLine_rect_big());
        line_rect_h.setItemCorlor(info.getLine_rect_h());
        line_rect_v.setItemCorlor(info.getLine_rect_v());

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bg_color_danshu:
            case R.id.bg_color_shuangshu:
            
            case R.id.title_color_qihao:
            case R.id.title_bg_color_qihao:
            case R.id.color_qihao:
            case R.id.bg_color_qihao:
            
            case R.id.title_color_qiansanzhi:
            case R.id.title_bg_color_qiansanzhi:
            case R.id.color_qiansanzhi:
            case R.id.bg_color_qiansanzhi:
            
            case R.id.title_color_kaijiang:
            case R.id.title_bg_color_kaijiang:
            case R.id.color_kaijiang:
            case R.id.bg_color_kaijiang:
            case R.id.double_bg_color_kaijiang:
            
            case R.id.title_color_qiansanfenbu:
            case R.id.title_bg_color_qiansanfenbu:
            case R.id.color_qiansanfenbu:
            case R.id.bg_color_qiansanfenbu:
            case R.id.double_bg_color_qiansanfenbu:
            case R.id.line_color_qiansanfenbu:
            
            case R.id.title_color_tongjizhi:
            case R.id.title_bg_color_tongjizhi:
            case R.id.color_tongjizhi:
            case R.id.bg_color_tongjizhi:
            
            case R.id.title_color_tuijian:
            case R.id.title_bg_color_tuijian:
            case R.id.color_tuijian:
            case R.id.bg_color_tuijian:
            
            case R.id.line_common_h:
            case R.id.line_common_v:
            case R.id.line_rect_h:
            case R.id.line_rect_v:
                showDialog(v);
                break;
            case R.id.line_common_small:
                line_common_small.setSelectButton(true);
                line_common_big.setSelectButton(false);
                break;
            case R.id.line_common_big:
                line_common_small.setSelectButton(false);
                line_common_big.setSelectButton(true);
                break;
            case R.id.line_rect_small:
                line_rect_small.setSelectButton(true);
                line_rect_big.setSelectButton(false);
                break;
            case R.id.line_rect_big:
                line_rect_small.setSelectButton(false);
                line_rect_big.setSelectButton(true);
                break;
            case R.id.bt_commit:
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_danshu", String.valueOf(bg_color_danshu.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_shuangshu", String.valueOf(bg_color_shuangshu.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_color_qihao", String.valueOf(title_color_qihao.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_bg_color_qihao", String.valueOf(title_bg_color_qihao.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this, "color_qihao",
                        String.valueOf(color_qihao.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_qihao", String.valueOf(bg_color_qihao.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_color_qiansanzhi", String.valueOf(title_color_qiansanzhi.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_bg_color_qiansanzhi",
                        String.valueOf(title_bg_color_qiansanzhi.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "color_qiansanzhi", String.valueOf(color_qiansanzhi.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_qiansanzhi", String.valueOf(bg_color_qiansanzhi.getTag()));
                
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_color_kaijiang", String.valueOf(title_color_kaijiang.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_bg_color_kaijiang",
                        String.valueOf(title_bg_color_kaijiang.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "color_kaijiang", String.valueOf(color_kaijiang.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_kaijiang", String.valueOf(bg_color_kaijiang.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "double_bg_color_kaijiang",
                        String.valueOf(double_bg_color_kaijiang.getTag()));
                
                
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_color_qiansanfenbu",
                        String.valueOf(title_color_qiansanfenbu.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_bg_color_qiansanfenbu",
                        String.valueOf(title_bg_color_qiansanfenbu.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "color_qiansanfenbu", String.valueOf(color_qiansanfenbu.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_qiansanfenbu", String.valueOf(bg_color_qiansanfenbu.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "double_bg_color_qiansanfenbu",
                        String.valueOf(double_bg_color_qiansanfenbu.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "line_color_qiansanfenbu",
                        String.valueOf(line_color_qiansanfenbu.getTag()));
                
                
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_color_tongjizhi", String.valueOf(title_color_tongjizhi.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_bg_color_tongjizhi",
                        String.valueOf(title_bg_color_tongjizhi.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "color_tongjizhi", String.valueOf(color_tongjizhi.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_tongjizhi", String.valueOf(bg_color_tongjizhi.getTag()));
                
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_color_tuijian", String.valueOf(title_color_tuijian.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "title_bg_color_tuijian", String.valueOf(title_bg_color_tuijian.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this, "color_tuijian",
                        String.valueOf(color_tuijian.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this,
                        "bg_color_tuijian", String.valueOf(bg_color_tuijian.getTag()));
                
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this, "line_common_h",
                        String.valueOf(line_common_h.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this, "line_common_v",
                        String.valueOf(line_common_v.getTag()));
                CorlorSettingPreferencesUtils.putBoolean(CorlorSettingActivity.this,
                        "line_common_small", line_common_small.isSelectButton());
                CorlorSettingPreferencesUtils.putBoolean(CorlorSettingActivity.this,
                        "line_common_big", line_common_big.isSelectButton());
                
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this, "line_rect_h",
                        String.valueOf(line_rect_h.getTag()));
                CorlorSettingPreferencesUtils.putString(CorlorSettingActivity.this, "line_rect_v",
                        String.valueOf(line_rect_v.getTag()));
                CorlorSettingPreferencesUtils.putBoolean(CorlorSettingActivity.this,
                        "line_rect_small", line_rect_small.isSelectButton());
                CorlorSettingPreferencesUtils.putBoolean(CorlorSettingActivity.this,
                        "line_rect_big", line_rect_big.isSelectButton());
                
                AppConfigManager.getInstance(getApplicationContext()).initColorsettingConfigs();

                Toast.makeText(getApplicationContext(), "保存设置成功!", Toast.LENGTH_SHORT).show();
                AppSettingActivity.sSaveConfig = true;
                CorlorSettingActivity.this.finish();
                
                break;
            default:
                break;
        }
    }



    private void showDialog(final View v) {
        mPriorityDlg.showDailog(new SelectItemListener() {
            
            @Override
            public void onItemClick(String colorValue) {
                ((ColorButton) v).setItemCorlor(colorValue);
            }
        });
    }
    
    private List<String> getColorList() {
        // 红色
        String red = "";
        // 绿色
        String green = "";
        // 蓝色
        String blue = "";
        // 生成随机对象
        Random random = new Random();
        
        List<String> list = new ArrayList<String>();
        
        for (int i = 0; i <= 255; i += 30) {
            // 生成红色颜色代码
            if (i > 255) {
                red = "ff";
            } else {
                red = Integer.toHexString(i).toUpperCase();
            }
            
            for (int j = 0; j <= 255; j += 30) {
                // 生成绿色颜色代码
                if (j > 255) {
                    green = "ff";
                } else {
                    green = Integer.toHexString(j).toUpperCase();
                }
                
                for (int k = 0; k <= 255; k += 30) {
                    if (k > 255) {
                        blue = "ff";
                    } else {
                        // 生成蓝色颜色代码
                        blue = Integer.toHexString(k).toUpperCase();
                    }
                    
                    // 判断红色代码的位数
                    red = red.length() == 1 ? "0" + red : red;
                    // 判断绿色代码的位数
                    green = green.length() == 1 ? "0" + green : green;
                    // 判断蓝色代码的位数
                    blue = blue.length() == 1 ? "0" + blue : blue;
                    // 生成十六进制颜色值
                    String color = "#" + red + green + blue;
                    list.add(color);
                }
            }
        }
        
        list.add("#ffffff");
        return list;
    }
    
}
